package com.modern.model;

import com.modern.model.BaseObject;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;

import java.io.Serializable;

@Entity
@Table(name="answer",catalog="typing")
public class Answer extends BaseObject implements Serializable {
    private Long answerId;
    private Paper paper;
    private String answerContent;
    private Long answerDuration;

    @Id @GeneratedValue(strategy=IDENTITY)     
    public Long getAnswerId() {
        return this.answerId;
    }
    
    public void setAnswerId(Long answerId) {
        this.answerId = answerId;
    }
@ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="paperId")
    public Paper getPaper() {
        return this.paper;
    }
    
    public void setPaper(Paper paper) {
        this.paper = paper;
    }
    
    @Column(name="answerContent", length=7000)
    public String getAnswerContent() {
        return this.answerContent;
    }
    
    public void setAnswerContent(String answerContent) {
        this.answerContent = answerContent;
    }
    
    @Column(name="answerDuration")
    public Long getAnswerDuration() {
        return this.answerDuration;
    }
    
    public void setAnswerDuration(Long answerDuration) {
        this.answerDuration = answerDuration;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Answer pojo = (Answer) o;

        if (paper != null ? !paper.equals(pojo.paper) : pojo.paper != null) return false;
        if (answerContent != null ? !answerContent.equals(pojo.answerContent) : pojo.answerContent != null) return false;
        if (answerDuration != null ? !answerDuration.equals(pojo.answerDuration) : pojo.answerDuration != null) return false;

        return true;
    }

    public int hashCode() {
        int result = 0;
        result = (paper != null ? paper.hashCode() : 0);
        result = 31 * result + (answerContent != null ? answerContent.hashCode() : 0);
        result = 31 * result + (answerDuration != null ? answerDuration.hashCode() : 0);

        return result;
    }

    public String toString() {
        StringBuffer sb = new StringBuffer(getClass().getSimpleName());

        sb.append(" [");
        sb.append("answerId").append("='").append(getAnswerId()).append("', ");
        sb.append("paper").append("='").append(getPaper()).append("', ");
        sb.append("answerContent").append("='").append(getAnswerContent()).append("', ");
        sb.append("answerDuration").append("='").append(getAnswerDuration()).append("'");
        sb.append("]");
      
        return sb.toString();
    }

}
